package org.example.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.code.Code;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Respond <E>{
    E data;

    Code code;

    String info;


    public static <E> Respond<E> creatRespond(E data,Code code,String info){
        return new Respond<>(data,code,info);
    }

    public static <E> Respond<E> creatRespond(Code code,String info){
        return new Respond<>(null,code,info);
    }




    public static <E> Respond<E> creatAuthSuccessRespond(E data,String info){
        return creatRespond(data,Code.AUTH_SUCCESS,info);
    }

    public static <E> Respond<E> creatAuthFailRespond(E data,String info){
        return creatRespond(data,Code.AUTH_FAIL,info);
    }

    public static <E> Respond<E> creatRegisterFailRespond(E data,String info){
        return creatRespond(data,Code.REGISTER_FAIL,info);
    }

    public static <E> Respond<E> creatRegisterSuccessRespond(E data,String info){
        return creatRespond(data,Code.REGISTER_SUCCESS,info);
    }

    public int getStatusCode(){
        return code.getCode();
    }

}
